package com.bite.book.model;

import com.bite.book.eunm.ResultEnum;
import lombok.Data;

@Data
public class Result<T> {
    private ResultEnum code;
    private T data;
    private String errMge;

    public static <T> Result success(T data){
        Result<T> result = new Result<>();
        result.setCode(ResultEnum.SUCCESS);
        result.setData(data);
        return result;
    }

    public static <T> Result UNLOGIN(){
        Result<T> result = new Result<>();
        result.setCode(ResultEnum.UNLOGIN);
        result.setErrMge("用户未登录，请先登录账户");
        return result;
    }

    public static <T> Result FAIL(){
        Result<T> result = new Result<>();
        result.setCode(ResultEnum.FAIL);
        return result;
    }

    public static <T> Result FAIL(String errMge){
        Result<T> result = new Result<>();
        result.setCode(ResultEnum.FAIL);
        result.setErrMge(errMge);
        return result;
    }
}
